#include "widget.h"
#include "ui_widget.h"
#include<QTimer>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    timer=new QTimer(this);
    ui->progressBar->setMaximum(100);
    ui->progressBar->setValue(0);

    connect(timer,&QTimer::timeout,this,&Widget::updataProgressbar);
    timer->start(100);


}

Widget::~Widget()
{
    delete ui;
}

void Widget::updataProgressbar()
{
    int value=ui->progressBar->value();
    if(value>=ui->progressBar->maximum())
    {
        timer->stop();//记得关闭定时器
        QTimer::singleShot(1000,this,[=](){
            this->close();
        });
        //[static] template <typename PointerToMemberFunction> void QTimer::singleShot(int msec, const QObject *receiver, PointerToMemberFunction method)
    }
    ui->progressBar->setValue(value+5);

}
